#include "dbg.h"
#include "stdarg.h"
#include "stdio.h"
#include "string.h"
#include "uart1.h"

static uint8_t mDisDbg = 1;//关闭调试输出

#ifdef DEBUG_INFO_ENABLE

/*debug info out buff*/
static uint8_t Tx_Buff[DBG_BUFF_SIZE];

/**
* @brief  debug info out
* @param  None
* @retval None
*/
void PrintfOut(const char* __format, ...)
{
  if(mDisDbg == 1)
    return;
  
  va_list ap;
  va_start(ap, __format);

  memset(Tx_Buff, 0x0, DBG_BUFF_SIZE);

  /*format string*/
  vsnprintf((char*)Tx_Buff, DBG_BUFF_SIZE, (const char *)__format, ap);
  va_end(ap);
  unsigned int len = strlen((const char*)Tx_Buff);
  
  /*send out*/
  UART1_SendData(Tx_Buff, len);
}

/**
* @brief  debug info out contain end word
* @param  None
* @retval None
*/
void PrintfBuffHex(uint8_t *p_buff, uint32_t len)
{
  uint32_t i;
  for(i=0;i<len;i++)
  {
    PrintfOut("%02X ", p_buff[i]);
  }
  PrintfOut("\r\n");
}

#endif

